<%--
   Icon Selector
   Copyright (c) 2013 ISPERP
   Version : 1.0.0
 --%>
<%@ tag language="java" pageEncoding="UTF-8"
	deferredSyntaxAllowedAsLiteral="false" trimDirectiveWhitespaces="true"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
<%@ attribute name="id" required="true" type="java.lang.String"
	description="唯一标识."%>
<%@ attribute name="valueControlId" required="false"
	type="java.lang.String" description="值所保存的空间的Id。"%>
<%@ attribute name="displayValue" required="false"
	type="java.lang.String" description="默认显示的值。"%>
<%@ attribute name="afterSelected" required="false"
	type="java.lang.String" description=""%>
<img id=${id } src="${displayValue }">
<a id="${id}Selector" class="icon icon-search ${selectorCssClass }"
	style="display: inline;padding:1px 0px" href="javascript:void(0);"><span
	style="display: inline-block;text-indent:-999em;width:16px;height:16px">选择</span>
</a>
<div id="${id }Dialog" title="请选择图标" style="display:none;padding:0">
	<iframe id="${id }IFrame" src="" scrolling="yes"
		style="border:none;width:100%;height:320px"></iframe>
	<jsp:doBody />
</div>
<div id="${id }Url" style="display:none">tags/selector/iconSelector?ctId=${id}</div>
<jsp:doBody />
<script type="text/javascript">
	$("#${id}Selector").click(function() {
		var url = $("#${id }IFrame").attr("src");
		if (url == null || url == "" || url == undefined) {
			$("#${id }IFrame").attr("src", $("#${id }Url").text());
		}
		$("#${id}Dialog").dialog("open");
		return false;
	});

	$("#${id}Dialog").dialog({
		width : 480,
		height : 400,
		modal : true,
		autoOpen : false,
		resizable : false,
		buttons : [{
			text : "关闭",
			"class" : 'grey',
			click : function() {
				$(this).dialog("close");
			}
		}]

	});
	function ${id}SetSelected(url) {
		if (url == undefined) {
			isperp.alert("请选择图标！");
			return false;
		}
		${afterSelected}

		$("#${valueControlId}").val(url);
		$("#${id}").attr("src", url);
		$("#${id}Dialog").dialog("close");
		return true;
	}
</script>